<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no'
          name='viewport'/>
    <meta charset="UTF-8">
    <title>马思特奥赛培训学校网络管理系统</title>
    <link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/demo.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/ready.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/ready.min.css}">
    <script type="text/javascript" th:src="@{/js/Vue.js}"></script>
    <!-- 引入组件库 -->
    <script type="text/javascript" th:src="@{/js/element-ui.js}"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" th:href="@{/css/element-ui.css}"/>
    <style>
        /* 大屏幕 ：大于等于1200px*/
        @media (min-width: 1200px) {
        }

        /*默认*/
        @media (min-width: 980px) {
        }

        /* 平板电脑和小屏电脑之间的分辨率 */
        @media (min-width: 768px) and (max-width: 480px) {
            .my-width {
                width: 300px !important;
            }
        }


        [v-cloak] {
            display: none !important;
        }
    </style>
</head>
<body>
<div class="wrapper" id="app" v-cloak>
    <!--    引入公共页面 public-index。html 的模块-->
    <div th:replace="admin/public-admin-index :: header"></div>

    <el-container style="height: 100%; border: 1px solid #eee">
        <div th:replace="admin/public-admin-index :: left"></div>


        <el-container>

            <el-main>
                <el-card class="box-card">

                    <div class="row">
                        <div class="col-md-5"></div>
                        <form class="form-inline">
                            <div class="form-group text-center">
                                <input type="text" class="form-control" id="userName" placeholder="按登录名查找">
                            </div>
                            <button type="button" class="btn btn-default" id="btn">搜索</button>
                        </form>

                    </div>

                    <div class="row">
                        <div class="col-md-3"></div>
                        <div class="col-md-6">
                            <table class="table" style="background-color:white;">
                                <tr style="background-color:rgba(211,255,205,0.98)">
                                    <th>院系</th>
                                    <th>专业</th>
                                    <th>班级</th>
                                    <th>学号</th>
                                    <th>姓名</th>
                                    <th>重置密码</th>
                                </tr>

                                <tr th:each="s: ${Students}">
                                    <td th:text="${s.institute_name}"></td>
                                    <td th:text="${s.specialty_name}"></td>
                                    <td th:text="${s.class_name}"></td>
                                    <td th:text="${s.stuNum}"></td>
                                    <td th:text="${s.name}"></td>
                                    <td>
                                        <button type="button" class="btn btn-info btn-xs"
                                                th:onclick="studAjax([[${s.stuNum}]]);">重置
                                        </button>
                                    </td>
                                </tr>
                            </table>
                        </div>
                        <div class="col-md-3"></div>
                    </div>


                </el-card>
            </el-main>
        </el-container>
    </el-container>

</div>


</body>

<script type="text/javascript" th:src="@{/webjars/jquery/1.9.1/jquery.js}"></script>
<script type="text/javascript" th:src="@{/webjars/bootstrap/3.3.7/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/js/Apexchart.js}"></script>
<script type="text/javascript" th:src="@{/asserts/js/ready.min.js}"></script>
<script type="text/javascript" th:src="@{/js/axios.js}"></script>

<script th:inline="javascript">

    var basePath = /*[[${#httpServletRequest.getContextPath()}]]*/'ContextPath';

    var mytable = new Vue({
        el: "#app",
        data() {
            return {
                url: basePath + "/admin/source",
                sources: [],
                source: {},
                flag: -1,
                drawer: false
            }
        },
        methods: {
            myMessage(data) {
                if (data.data.code == 100) {
                    this.$notify({
                        title: '成功',
                        message: '操作成功',
                        type: 'success',
                        position: 'top-right',
                    });
                } else {
                    this.$notify({
                        title: '错误',
                        dangerouslyUseHTMLString: true,
                        message: '操作错误：<br>' + data.data.msg,
                        type: 'error',
                        position: 'top-right',
                    });
                }
            },
            page() {
                axios.get(this.url + "s"
                ).then((data) => {
                    this.sources = data.data.extend.sources;
                })
            },
            add() {
                axios.post(this.url, this.source).then((data) => {
                    this.myMessage(data);
                    this.page();
                })
            },
            del(index) {
                this.$confirm('此操作将永久删除, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.delete(this.url, {
                        data: this.sources[index]
                    }).then((data) => {
                        this.myMessage(data);
                        this.page();
                    });

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });

            },
            update(index) {
                this.flag = index;
            },
            updateSave(index) {
                this.flag = -1;
                axios.put(this.url, this.sources[index]).then((data) => {
                    this.myMessage(data);
                });
            }
        },
        mounted() {
            this.page();
        }
    });
    $("#btn").click(function () {
        var username = $("#userName").val()
        window.location.href = "/edumanagement/admin/selectStudent?username=" + username;
    })

    function studAjax(username) {
        //用户账号登入判断
        $.ajax({
            url: "czpwd",
            type: "POST",
            async: false,
            data: {"username": username},
            contentType: 'application/x-www-form-urlencoded',
            dataType: 'json',
            success: function (PD) {
                if (PD.pd == 0) {
                    alert("重置失败");
                } else if (PD.pd == 1) {
                    alert("重置成功");
                    window.location.href = "czstudentpwd";
                }
            },
            error: function (data) {
                alert("失败");
            }
        })
    }
</script>
</html>